package pCloud.stream;

/*
 * The Filter box class
 * Each filter has a logic predicate to represent the filter condition
 * 
 */
public class FilterBox {
	
	public String filtercondition;
	public String mergeMsg; // used to store NR/PR information after merging
	
	public FilterBox(){
		
		this.filtercondition = "";
		this.mergeMsg = "";
	}
	
	public FilterBox(String con) {
		
		this.filtercondition = con;
		this.mergeMsg = "";
	}
	
	/*
	public String toXACML() {
		
		String xacml="";
		
		xacml += "<Obligation ObligationId=\"" + PCloudAttributeAndType.OBLIGATION_STREAM_FILTER + "\" FulfillOn=\"Permit\">" + Global.eol;    
	    xacml += "<AttributeAssignment AttributeId=\"" + PCloudAttributeAndType.OBLIGATION_STREAM_FILTER_CONDITION + "\" DataType=\"" + PCloudAttributeAndType.TYPE_STRING+"\">";
	    xacml += this.filtercondition;
	    xacml += "</AttributeAssignment>" + Global.eol;
	    xacml += "</Obligation>" + Global.eol;
		
		return xacml;
	}
	*/
	
	public void print() {
		
		System.out.println("Filter Condition -> " + this.filtercondition);
	}
	
	public String createSSQL(String input,String output){
		
		String ssql="";
		
		ssql+="SELECT * FROM " + input + Global.eol + " WHERE " + this.filtercondition + Global.eol + "INTO " + output;
		
		ssql+=";" + Global.eol;
		return ssql;
	}
	
	/*
	public static void main (String[] args){
		FilterBox fb = new FilterBox("a>=100 && b <= 100");
		System.out.println(fb.toXACML());
		System.out.println(fb.createSSQL("weather", "out_2"));
	}
	*/
}
